package core;

import java.sql.SQLException;

import utils.MetodosAuxiliares;
import acessoDados.Singleton;
import constants.ProjectConstants;

public class ReservaActiva implements EstadoReserva { 
	
	@SuppressWarnings("static-access")
	public int cancela(Reserva reserva) throws SQLException, ClassNotFoundException{
		Singleton.getInstance().getReservaDAO().cancelaReserva(""+reserva.getIdReserva());

		if(reserva.getTipoPagamento().equalsIgnoreCase(ProjectConstants.TROCAR_MILHAS)){
			Singleton.getInstance().getPessoaDAO().addMilhas(reserva.getLogin(), MetodosAuxiliares.calculaMilhas(""+reserva.getIdViagem()));
		}
		else{
			//devolver dinheiro
		}
		
		return 1;
	}

	@SuppressWarnings("static-access")
	public int expira(Reserva reserva) throws SQLException, ClassNotFoundException{
		Singleton.getInstance().getReservaDAO().expiraReserva(""+reserva.getIdReserva());
		return 1;
	}

}
